package com.drobot;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class SqlLite {

	private String path;
	private Connection connection;
	private Statement statement;
	
	
	public SqlLite(String path) {
		this.path = path;
		
		try {
			Class.forName("org.sqlite.JDBC");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}
	
	public Connection createConnection(){
		try {
			connection = DriverManager.getConnection("jdbc:sqlite:" + path);
		}catch (SQLException e) {
			e.printStackTrace();
		}
		
		return connection;
	}
	
	public Statement createStatement(){
		try {
			statement = connection.createStatement();
		}catch (SQLException e) {
			e.printStackTrace();
		}
		
		return statement;
	}

	public void closeConnection(){
		if (connection != null){
			try {
				connection.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
	}
	
	public void closeStatement(){
		if (statement != null){
			try {
				statement.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
	}
	
	

}
